package com.linktrip.devicesmanager.main;

public class DataShow {
	/*
	 * 0x36, 0x00, 0x02, 0x00, 0x01, 0x1e, 0x00, 0x00, 0x24, 0x37, 0x81, 0x06,
	 * 0x56, 0x97, 0xac, 0x5b, 0x04, 0x01, 0x01, 0x5f, 0x12, 0x00, 0x00, 0x1e,
	 * 0x84, 0xa9, 0x1c, 0x49, 0x38, 0x19, 0x3f, 0x40, 0x7c, 0x55, 0x78, 0xe1,
	 * 0x98, 0x60, 0x5e, 0x40, 0xe1, 0x07, 0x02, 0x0a, 0x0d, 0x2e, 0x19, 0x00,
	 * 0x01, 0x16, 0x30, 0x00, 0x29, 0x00, 0x00, 0x00
	 */

	/**
	 * public static byte[] temp = { 0x36, 0x00, 0x02, 0x00, 0x01, 0x1e, 0x00,
	 * 0x00, 0x24, 0x37, 0x81, 0x06, 0x56, 0x97, 0xac, 0x5b, 0x04, 0x01, 0x01,
	 * 0x5f, 0x12, 0x00, 0x00, 0x1e, 0x84, 0xa9, 0x1c, 0x49, 0x38, 0x19, 0x3f,
	 * 0x40, 0x7c, 0x55, 0x78, 0xe1, 0x98, 0x60, 0x5e, 0x40, 0xe1, 0x07, 0x02,
	 * 0x0a, 0x0d, 0x2e, 0x19, 0x00, 0x01, 0x16, 0x30, 0x00, 0x29, 0x00, 0x00,
	 * 0x00 };
	 **/
	public static byte[] temp = {0x36,0x00,0x00,0x02,0x01,0x14,0x00,0x00,0x00,0x00,
			0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
			0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			(byte) 0xe1,0x07,0x06,0x02,0x0b,0x13,0x02,(byte) 0x8d,0x01,0x00,
			0x00,0x00,0x00,0x00,0x00,0x3c};

	public static void main(String[] args) {

		System.out.println("length:" + (0xff & temp[1] + 0xff & temp[0]));
		System.out.println("version:" + (0xff & temp[3] + 0xff & temp[2]));
		System.out.println("type:" + (0xff & temp[4]));
		System.out.println("messageId:" + (0xff & temp[6] + 0xff & temp[5]));
		System.out.println("sosflag:" + (0xff & temp[7]));
		System.out.println("deviceId:" + ("" + checkLen(Integer.toHexString(0xff & temp[8]))
				+ checkLen(Integer.toHexString(0xff & temp[9])) + checkLen(Integer.toHexString(0xff & temp[10]))
				+ checkLen(Integer.toHexString(0xff & temp[11])) + checkLen(Integer.toHexString(0xff & temp[12]))
				+ checkLen(Integer.toHexString(0xff & temp[13])) + checkLen(Integer.toHexString(0xff & temp[14]))
				+ checkLen(Integer.toHexString(0xff & temp[15]))));
		System.out.println("sysVersion:" + (0xff & temp[16]));
		System.out.println("mode:" + (0xff & temp[17]));
		System.out.println("lockStatus:" + (0xff & temp[18]));
		System.out.println("batteryStaus:" + (0xff & temp[19]));
		System.out.println("charge:" + (0xff & temp[20]));
		System.out.println("blinkStatus:" + (0xff & temp[21]));
		System.out.println("beepCount:" + (0xff & temp[22]));
		System.out.println("singature:" + (0xff & temp[23]));
		System.out
				.println(
						"latitude:" + Double.longBitsToDouble(Long.valueOf(
								Integer.toHexString(0xff & temp[31]) + Integer.toHexString(0xff & temp[30])
										+ Integer.toHexString(0xff & temp[29]) + Integer.toHexString(0xff & temp[28])
										+ Integer.toHexString(0xff & temp[27]) + Integer.toHexString(0xff & temp[26])
										+ Integer.toHexString(0xff & temp[25]) + Integer.toHexString(0xff & temp[24]),
								16)));
		System.out.println("longitude:" + Double.longBitsToDouble(Long
				.valueOf(checkLen(Integer.toHexString(0xff & temp[39])) + checkLen(Integer.toHexString(0xff & temp[38]))
						+ checkLen(Integer.toHexString(0xff & temp[37]))
						+ checkLen(Integer.toHexString(0xff & temp[36]))
						+ checkLen(Integer.toHexString(0xff & temp[35]))
						+ checkLen(Integer.toHexString(0xff & temp[34]))
						+ checkLen(Integer.toHexString(0xff & temp[33]))
						+ checkLen(Integer.toHexString(0xff & temp[32])), 16)));
		int msec = Integer.parseInt(Integer.toHexString(0xff & temp[47]), 16);
		int second = Integer.parseInt(Integer.toHexString(0xff & temp[46]), 16);
		int min = Integer.parseInt(Integer.toHexString(0xff & temp[45]), 16);
		int hour = Integer.parseInt(Integer.toHexString(0xff & temp[44]), 16);
		int day = Integer.parseInt(Integer.toHexString(0xff & temp[43]), 16);
		int month = Integer.parseInt(Integer.toHexString(0xff & temp[42]), 16);
		int year = Integer.parseInt(Integer.toHexString(0xff & temp[41]) + Integer.toHexString(0xff & temp[40]), 16);
		String timeStamp = formatStr(year) + "/" + formatStr(month) + "/" + formatStr(day) + " " + formatStr(hour) + ":"
				+ formatStr(min) + ":" + formatStr(second) + "." + formatStr(msec);
		System.out.println("timeStamp:" + timeStamp);
		System.out.println("hdwareVer : " + (0xff & temp[48]));
		System.out.println("temp : " + (0xff & temp[49]));
		System.out.println("vBus : " + (0xff & temp[50]));
		System.out.println("iCharge : " + (0xff & temp[51]));
		System.out.println("vBattery : " + (0xff & temp[52]));
		System.out.println("N/A : " + (0xff & temp[53]));
		System.out.println("N/A : " + (0xff & temp[54]));
		System.out.println("CRC : " + (0xff & temp[55]));
	}

	public static String formatStr(int len) {
		if (len < 10)
			return "0" + len;
		return String.valueOf(len);
	}

	public static String checkLen(String temp) {
		if (temp.length() < 2)
			return "0" + temp;

		return temp;
	}
}
